#!/usr/bin/env python
"""
	errors.py - Error Handling and Logging if logging is enabled.
    Copyright (C) 2011  The FunnyBot Team

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
"""

class errors(object):
	print_errors = True
	logging = False
	loglevel = "ERROR"
	logfile = "log.txt"
	
	def __init__(self,print_errors=True):
		self.print_errors = print_errors
	
	def init_log(self,loglevel="ERROR",logfile="log.txt",logging=True):
		self.logging = logging
		self.loglevel = loglevel
		self.logfile = logfile
	
	def print_err(self,error="There was an error!",level="NOTICE"):
		if self.print_errors:
			print("%s: %s" % (level, error))
		if self.logging:
			self.log(self,error,level)
	
	def log(self,error="There was an error!",level="NOTICE"):
		pass #will implement later :P